/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Project2.cs342.project1.mathNotebook.Database;

import java.math.BigInteger;
import java.sql.Connection;

/**
 *
 * @author Rick
 */
public class DBTestDriver {
    public static DBNotebooks notebooks;
    public static DBGroupAccess groupAccess;
    public static DBGroupMembers groupMember;
    public static DBGroups groups;
    public static DBUsers users;
    public static SQLConfigeration sqlConfig;
    public static Connection conn;

    public static void main(String[] args){

        conn = sqlConfig.getConnection();
        //runGroupAccess();
        runGroupMembers();
        //runGroups();
        //runUsers();
        //runNotebooks();

    }

    public static void runNotebooks(){

        notebooks = new DBNotebooks();
        notebooks.insertIntoNotebooks("test2.encrypt",
                null,null,null, null, null);
//        notebooks.deleteNotebookFile("test2.encrypt");
        notebooks.retrieveNotebooksContents("test2.encrypt",null);

    }
    
    public static void runGroupAccess(){

        groupAccess = new DBGroupAccess();
//        groupAccess.insertIntoGroupAccess("Group 7", "test3.encrypt");
        String[] str = groupAccess.retrieveFilesForGroup("Group 6");
        for(int i = 0; i < str.length; i++){
            System.out.println(str[i]);
        }
//        String[] str2 = groupAccess.retrieveGroupForFiles("test3.encrypt");
//        for(int i = 0; i < str2.length; i++){
//            System.out.println(str2[i]);
//        }
//        groupAccess.deleteRowFromGroupAccess("Group 6", "test3.encrypt");
        
    }

    public static void runGroupMembers(){

        groupMember = new DBGroupMembers();
        
//        groupMember.insertIntoGroupMembers("Group 7", "Rick");
//        groupMember.insertIntoGroupMembers("Group 6", "Matt");
//        groupMember.insertIntoGroupMembers("Group 6", "Kevin");
//        groupMember.deleteRowFromGroupMembers("Group 6", "Matt");
        String[] str = groupMember.retrieveGroupsForUser("Rick");
        for(int i = 0; i < str.length; i++){
            System.out.println(str[i]);
        }
//        String[] str2 = groupMember.retrieveGroupsForUser("Matt");
//        for(int i = 0; i < str2.length; i++){
//            System.out.println(str2[i]);
//        }
    }

    public static void runGroups(){
        groups = new DBGroups();
        //groups.insertIntoGroups("Group 6", "read/write");
        //groups.updateAccessLevel("Group 6", "read");
        System.out.println(groups.retrieveGroupAccessLevel("Group 6"));
        //groups.deleteGroup("Group 7");
    }

    public static void runUsers(){
        users = new DBUsers();
        users.insertIntoUsers("rick", "password");
//        users.deleteRowFromUsers("Rick");
//        users.doesUserExist("Rick");
        users.checkLogin("Rick", "password");

    }
}
